package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * 读取文件
 */
public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
        //将当前源代码输出到控制台
        File file = new File("./src/main/java/io/ReadStringDemo.java");
        FileInputStream fis = new FileInputStream(file);
        long len = file.length();
        byte []data = new byte[(int) len];
        fis.read(data);
        //用utf-8还原
        String line = new String(data,StandardCharsets.UTF_8);
        System.out.println(line);
    }
}
